package com.tcm.doctor.web.controller;

import com.base.core.utils.R;
import com.tcm.doctor.domain.dto.DoctorAccountDto;
import com.tcm.doctor.service.DoctorAccountService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/doctor")
@RestController
public class DoctorAccountController {

    @DubboReference(version = "0.0.1-alpha", timeout = 6000, check = false, retries = 3)
    private DoctorAccountService doctorAccountService;

    @GetMapping("/account/view")
    public R view(@RequestParam("userId") Long userId) {
        return R.success(doctorAccountService.findByUserId(userId));
    }

    @PostMapping("/account/save")
    public R create(@RequestBody DoctorAccountDto doctorAccountDto) {
        try{
            doctorAccountService.save(doctorAccountDto);
        }catch (Exception e){
            return R.fail(e.getMessage());
        }
        return R.success();
    }

}

